import 'package:bxultimate/widgets/mk_page.dart';
import 'package:bxultimate/widgets/mk_scroll_view.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:quill_html_editor/quill_html_editor.dart';
import 'package:tdesign_flutter/tdesign_flutter.dart' hide TDInput, TDInputType;
import 'package:bxultimate/widgets/app/app_input.dart';
import 'controller.dart';

class OrganizationAnnouncementPublishPage extends StatefulWidget {
  const OrganizationAnnouncementPublishPage({Key? key}) : super(key: key);

  @override
  State<OrganizationAnnouncementPublishPage> createState() =>
      _OrganizationAnnouncementPublishPageState();
}

class _OrganizationAnnouncementPublishPageState
    extends State<OrganizationAnnouncementPublishPage> {
  final controller = Get.find<OrganizationAnnouncementPublishController>();
  final state = Get.find<OrganizationAnnouncementPublishController>().state;

  @override
  Widget build(BuildContext context) {
    return MkPage(
        child: Scaffold(
      backgroundColor: Colors.transparent,
      appBar: TDNavBar(
        backgroundColor: Colors.transparent,
        title: '发布公告',
      ),
      body: MkScrollView(
        bottomButton: TDButton(
          text: '确认发布',
          shape: TDButtonShape.circle,
          height: 48,
          isBlock: true,
          onTap: controller.publish,
          theme: TDButtonTheme.primary,
        ),
        children: [
          TDInput(
            controller: controller.titleEditController,
            required: true,
            hintText:'请输入标题',
            leftLabel: '标题',
            type: TDInputType.special,
            textAlign: TextAlign.end,
            backgroundColor: Colors.transparent,
          ),
          TDInput(
            controller: controller.descEditController,
            required: true,
            hintText: '请输入描述',
            leftLabel: '描述',
            type: TDInputType.special,
            textAlign: TextAlign.end,
            backgroundColor: Colors.transparent,
          ),

          ToolBar(
            toolBarColor: controller.toolbarColor,
            padding: const EdgeInsets.all(8),
            iconSize: 16,
            iconColor: controller.toolbarIconColor,
            activeIconColor: Colors.greenAccent.shade400,
            controller: controller.editorController,
            crossAxisAlignment: WrapCrossAlignment.start,
            direction: Axis.horizontal,
          ),
          SizedBox(
            height: 500,
            child: QuillHtmlEditor(
              text: "",
              hintText: '开始输入...',
              controller: controller.editorController,
              isEnabled: true,
              ensureVisible: false,
              minHeight: 500,
              autoFocus: false,
              textStyle: controller.editorTextStyle,
              hintTextStyle: controller.hintTextStyle,
              hintTextAlign: TextAlign.start,
              padding: const EdgeInsets.only(left: 10, top: 10),
              hintTextPadding: const EdgeInsets.only(left: 20),
              backgroundColor: controller.backgroundColor,
              inputAction: InputAction.newline,
              onTextChanged: controller.onTextChanged,
            ),
          )
        ],
      ),
    ));
  }



  @override
  void dispose() {
    Get.delete<OrganizationAnnouncementPublishController>();
    super.dispose();
  }
}
